package com.imooc.utils;

import com.imooc.dataobject.ProductInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;

import java.util.List;

public class ConvertUtil {

    public static List<ProductInfo> page2List(Page<ProductInfo> page) {
        return page.getContent();
    }

    public static Page<ProductInfo> list2Page(List<ProductInfo> list, Pageable pageable) {
        return new PageImpl<>(list, pageable, list.size());
    }
}
